package com.woniu.staff.client;

import com.woniu.model.Result;
import com.woniu.staff.client.dto.AddAccountRoleDto;
import com.woniu.staff.cliententity.dto.AccountDto;
import com.woniu.staff.cliententity.form.AccountLoginForm;
import com.woniu.staff.cliententity.form.AddAccountForm;
import com.woniu.staff.cliententity.form.AddAccountRoleForm;
import com.woniu.staff.cliententity.model.Account;
import com.woniu.staff.cliententity.model.AccountRole;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(name = "permissions-server",path = "/permissions")
public interface PermissionsClient {
    /**
     * 新增账号
     * @param form
     * @return
     */
    @PostMapping("/account/addAccount")
    Result<Account> addAccount(@RequestBody AddAccountForm form);

    /**
     * 根据手机号查询是否有账号存在
     * @param phone 手机号
     * @return
     */
    @GetMapping("/account/selectAccount/{phone}")
    Result<Account> selectAccount(@PathVariable("phone") String phone);

    /**
     * 登录查询账号
     * @param form
     * @return
     */
    @PostMapping("/account/login")
    Result<AccountDto> login(@RequestBody AccountLoginForm form);

    /**
     * 新增账号角色关联
     * @param form
     * @return
     */
    @PostMapping("/accountRole/addAccountRole")
    Result<AddAccountRoleDto> addAccountRole(@RequestBody AddAccountRoleDto form);

    /**
     * 新增账号角色关联
     * @param form 账号id 角色id
     * @return
     */
    @ApiOperation("新增账号角色关联")
    @PostMapping("/accountRole/addAccountRole")
    Result<AccountRole> addAccountRole(@RequestBody AddAccountRoleForm form);
}
